package org.example;

class Solution {
    public String predictPartyVictory(String senate) {
        boolean[] status = new boolean[senate.length()];
        int rDead = 0;
        int dDead = 0;
        int rDeadCache = 0;
        int dDeadCache = 0;
        int rCount = 0;
        int dCount = 0;
        for (int i = 0; i < senate.length(); i++) {
            if (senate.charAt(i) == 'R') {
                rCount++;
            } else {
                dCount++;
            }
        }
        while (true) {
            for (int i = 0; i < senate.length(); i++) {
                if (status[i]) {
                    continue;
                }
                if (senate.charAt(i) == 'R') {
                    if (rDeadCache > 0) {
                        status[i] = true;
                        rDeadCache--;
                        rDead++;
                        continue;
                    }
                    dDeadCache++;
                } else {
                    if (dDeadCache > 0) {
                        status[i] = true;
                        dDeadCache--;
                        dDead++;
                        continue;
                    }
                    rDeadCache++;
                }
                if (rDead == rCount || dDead == dCount) {
                    return rDead == rCount ? "Dire" : "Radiant";
                }
            }
        }
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}